﻿namespace AutoClickTool.Common
{
    public static class KeysDic
    {
        static KeysDic()
        {
            var codes = (Keys[])Enum.GetValues(typeof(Keys));
            Data = new Dictionary<string, Keys>();
            try
            {
                foreach (var code in codes)
                {
                    var name= code.ToString().ToUpper();
                    if (!Data.ContainsKey(name))
                    {
                        Data.Add(name, code);
                    }
                }
                Data.Add("ENTER", Data["RETURN"]);
            }
            catch (Exception e)
            {

                throw;
            }
        }
        private static Dictionary<string, Keys> Data { get; }
        /// <summary>
        /// 转换键
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public static Keys? ConvertToKeys(this string key)
        {
            if (Data.ContainsKey(key)) { 
                return Data[key];
            }
            return null;
        }
    }
}
